<template>
  <template v-for="item in push.tab">
    <component v-if="cfg.route.query.type2 == item.ck" :is="item.comp" :push="push" />
  </template>
</template>

<script>
import { cfg } from "@/cfg/cfg.js";
import { useRoute, useRouter } from "vue-router";

export default defineComponent({
  props: {
    push: { required: true },
    push2: {},
  },
  setup(props) {
    let val = reactive({
      tabck: null,
    });
    let ct = {};

    ct.tab = (tab) => {
      //浅拷贝tab
      const back = { ...tab };
      tab = back.ck;
      let push = {};
      cfg.router.push({
        query: {
          type: cfg.route.query.type,
          type2: tab,
          ...push,
          ...back.push,
        },
      });
    };

    props.push.tab.forEach((item, key) => {
      props.push.tab[key].tab = ct.tab;
    });

    cfg.menulv2 = props.push.tab;

    return {
      ct,
      val,
      cfg,
    };
  },
  mounted() {
    if (cfg.route.query?.type2 == null) {
      cfg.router.push({
        query: {
          ...cfg.route.query,
          type2: "team_rank",
        },
      });
    } else {
      cfg.router.push({
        query: {
          ...cfg.route.query,
        },
      });
    }
  },
});
</script>
